{extend name='table'}

{block name="button"}
<button data-modal='{:url("add")}' data-title="{:lang('添加计划')}"   data-width="1000px" class='layui-btn layui-btn-sm layui-btn-primary'>{:lang('添加计划')}</button>

<a data-confirm="确定永久删除这些计划吗？" data-table-id="UserTable" data-action='{:url("remove")}' data-rule="id#{id}" class='layui-btn layui-btn-sm layui-btn-primary'>{:lang('批量删除')}</a>

{/block}

{block name="content"}
<div class="layui-tab layui-tab-card">
    <div class="layui-tab-content">
        {include file='class_plan_task/index_search'}
        <table id="UserTable" data-url="{:sysuri('index')}" data-target-search="form.form-search"></table>
    </div>
</div>
<script>
    $(function () {
        $('#UserTable').layTable({
            even: true, height: 'full',
            cols: [[
                {checkbox: true, fixed: true},
                {field: 'id', title: '{:lang("ID")}', align: 'center', width: 80, sort: true},
                {field: 'name', title: '{:lang("标题")}', align: 'center', minWidth: 170},
                {field: 'parent_id', title: '{:lang("所属计划")}', minWidth: 100, align: 'center', templet: function(d){
                    return d.plan && d.plan.name ? d.plan.name : '-';
                }},
                {field: 's_date', title: '{:lang("学习日期")}', align: 'center', minWidth: 170},
                {field: 'week', title: '{:lang("第几周")}', align: 'center', minWidth: 170},
                {field: 'user_id', title: '{:lang("用户")}', align: 'center', minWidth: 100, templet: function(d){
                    return d.user && d.user.full_name ? d.user.full_name : '-';
                }},
                {field: 'phone', title: '{:lang("手机号")}', align: 'center', minWidth: 170, templet: function(d){
                    return d.user && d.user.phone ? d.user.phone : '-';
                }},

               
                {field: 'create_time', title: '{:lang("创建时间")}', align: 'center', minWidth: 170, sort: true},
                {toolbar: '#toolbar', title: '{:lang("操作面板")}', align: 'center', minWidth: 180, fixed: 'right'}
            ]]
        });

        // 数据状态切换操作
        layui.form.on('switch(StatusSwitch)', function (obj) {
            var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
            $.form.load("{:url('state')}", data, 'post', function (ret) {
                if (ret.code < 1) $.msg.error(ret.info, 3, function () {
                    $('#UserTable').trigger('reload');
                }); else {
                    $('#UserTable').trigger('reload')
                }
                return false;
            }, false);
        });
    });
</script>



<script type="text/html" id="toolbar">

    <a class="layui-btn layui-btn-sm"  data-width="1000px" data-event-dbclick data-title="{:lang('编辑用户')}" data-modal='{:url("edit")}?id={{d.id}}'>{:lang('编 辑')}</a>

    <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="{:lang('确定要永久删除吗？')}" data-action="{:url('remove')}" data-value="id#{{d.id}}">{:lang('删 除')}</a>

</script>
{/block}
